/* eslint-disable no-restricted-syntax */
/* eslint-disable no-unused-vars */
const data = require('./ANALYTIC_TYPE_NUMS.json')

// yyyy-mm-dd
function getDate() {
  function twoDigit(n) { return n < 10 ? `0${n}` : n }
  const now = new Date();
  return `${now.getFullYear()}-${twoDigit(now.getMonth() + 1)}-${twoDigit(now.getDate())}`;
}

function getMapping() {
  for (const [key, value] of Object.entries(data)) {
    if (key.length >= 100) {
      console.log('ID不能超过100个字符', key, value.eventId)
      return
    }
    if (key !== value.eventId) {
      console.log('ERROR NAME', key, value.eventId)
    }
    const isNUM = key.startsWith('num')

    // 友盟事件
    console.log(`${key},${value.eventLabel || '默认'}, ${isNUM ? 0 : 1}`)
  }
}

function getGithubMapping() {
  for (const [key, value] of Object.entries(data)) {
    if (key.length >= 100) {
      console.log('ID不能超过100个字符', key, value.eventId)
      return
    }
    if (key !== value.eventId) {
      console.log('ERROR NAME', key, value.eventId)
    }
    // p8hCare Wiki Page
    console.log(`|   ${value.createDate || getDate()}   |  ${key}   |   ${value.eventLabel}     |    |  ${value.params || '-'}   |  |`)
  }
}

console.log(' ========= UMENG Mapping Event ========')
getMapping()
console.log(' ========= END UMENG Mapping Event ========')

console.log(' ========= Github WIKI PAGE ========')
getGithubMapping()
console.log(' ========= END Github WIKI PAGE ========')
